def f1():
    l = [[], []]
    while 1:
        try:
            x = yield l
            print(x)
            if isinstance(x,int):
                l[0].append(x)
            else:
                l[1].append(x)
        except:
            return l


f = f1()
next(f)

f.send(1)
f.send(2)
f.send('saf')
f.send('13')
try:
    f.throw(StopIteration)
except Exception as e:
    a = e.value

print(a)




# def mytest():
#     while 1:
#         res = yield   # yield 协程的功能   res 接受外部send 的值
#         print(res)
#
# t = mytest()
# next(t)     # 激活上面的程序 或者 t.send(None)
#
# t.send('1')    # send 的值传递给 yield 等号左边
# print(t.send('2'))
# print(t.send('3'))
# print(t.send('4'))